package com.kalaqia.image.di.module;

import android.graphics.Bitmap;

import com.bumptech.glide.RequestBuilder;
import com.kalaqia.image.di.observable.SimpleTargetObservable;
import com.kalaqia.image.library.IImageLoaderStrategy;
import com.kalaqia.image.library.ImageLoaderManager;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import io.reactivex.Observable;

/**
 * function:
 * project:kalaqia
 * describe:
 * created owner:kalaqia 421407393@qq.com
 * created date:2017/8/4 14:15
 */
//<editor-fold desc="version update log">
// update owner:kalaqia  421407393@qq.com
// update datetime:2017/8/4 14:15
// update remark:
//</editor-fold>
@Module
public class ImageLoaderModule {

    @Singleton
    @Provides
    public ImageLoaderManager providerImageLoader(IImageLoaderStrategy strategy) {
        ImageLoaderManager manager = ImageLoaderManager.getInstance();
        manager.setLoaderStrategy(strategy);
        return manager;
    }

    @Provides
    public Observable<Bitmap> provideSimpleTargetObservable(Observable<RequestBuilder> builderObservable) {
        return builderObservable.concatMap(SimpleTargetObservable::new);
    }

}
